/*
 Example 3.2 – interrupts
 Created 21/04/2010 —  By John Boxall — http://tronixstuff.wordpress.com —  CC by-sa v3.0
 Just send some data to the LCD, whilst monitoring two interrupts
*/

#include <LiquidCrystal.h> // we need this library for the LCD commands

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

float noisy = 0;

void setup() 
{
  lcd.begin(16, 2);             // need to specify how many columns and rows are in the LCD unit
  lcd.setCursor(0,0);
  lcd.println("* example 3.2 * ");
  lcd.setCursor(0,1);
  lcd.println("tronixstuff.com ");
  lcd.setCursor(0,1);
  delay(4000);
  lcd.clear();
  randomSeed(analogRead(0)); // reseed the random number generator with some noise
 
  attachInterrupt(0, panicone, HIGH); // so when interrupt zero (digital pin 2) changes state, it will trigger the interrupt and go to function 'panicone'
  attachInterrupt(1, panictwo, HIGH); // so when interrupt one (digital pin 3) changes state, it will trigger the interrupt and go to function 'panicone' 
}

void loop() 
{
  noisy=random(1000);
  lcd.setCursor(0,0);
  lcd.print("Random Numbers!");
  lcd.setCursor(0,1);
  lcd.print("Number: ");
  lcd.print(noisy,0);
  delay(1000);
}

void panicone()
{
  lcd.clear();
  lcd.println("Interrupt one   ");
}
   
void panictwo()
{
  lcd.clear();
  lcd.println("Interrupt two   ");
}
   
